package Java8实战._2_Stream_使用流._2_映射;

import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class _2_流的扁平化2 {

    public static void main(String[] args) {
        String[] arrays = {"Goodbye","World"};
        Stream<String> stringStream = Arrays.stream(arrays);

        List<String[]> collect = stringStream.map((String str) -> str.split(""))
                .distinct()
                .collect(Collectors.toList());

        for (String[] strings : collect){
            for (String str : strings){
                System.out.print(str);
            }
            System.out.println();
        }
    }

    public static <T> void print(List<T> list, Consumer<T> consumer){
        for (T t : list){
            consumer.accept(t);
        }
    }
}
